package database

import (
	"JoRedis/interface/reply"
)

const (
	flagWrite = 0
	flagRead  = 1
)

// CmdExecFun redis命令执行
type CmdExecFun func(dbPtr *DB, argBytesSlc [][]byte) reply.ReplyItf

// PreFun analyses command line when queued command to `multi`
// returns related write keys and read keys
type PreFun func(args [][]byte) ([]string, []string)

// UndoFun 返回指定命令行的undo日志
// execute from head to tail when undo
type UndoFun func(db *DB, args [][]byte) [][][]byte

func readFirstKey(args [][]byte) ([]string, []string) {
	// assert len(args) > 0
	key := string(args[0])
	return nil, []string{key}
}

func writeFirstKey(args [][]byte) ([]string, []string) {
	key := string(args[0])
	return []string{key}, nil
}

func rollbackFirstKey(db *DB, args [][]byte) [][][]byte {
	//key := string(args[0])
	return nil
}
